<template>
  <li :class="{ completed: completed }">
    <input type="checkbox" :checked="completed" @change="toggleCompletion" />
    {{ title }}
    <button @click="removeTodo">删除</button>
  </li>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      required: true
    },
    completed: {
      type: Boolean,
      required: true
    }
  },
  methods: {
    toggleCompletion() {
      this.$emit('update:completed', !this.completed);
    },
    removeTodo() {
      this.$emit('remove-todo');
    }
  }
};
</script>

<style scoped>
li.completed {
  text-decoration: line-through;
  color: #888;
}
</style>